package com.wn.utils;

import org.springframework.boot.autoconfigure.r2dbc.R2dbcProperties;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @ author     ：NST
 * @ date       ：Created in 2022/10/24 11:53
 * @ description：线程工具类
 * @ modified By：
 * @ version:
 */

public class ThreadUtil {
    public ThreadPoolExecutor poolExecutor;

    private ThreadUtil() {
        /*
         * 1.核心线程数
         * 2.最大线程数
         * 3.空闲时间
         * 4.空闲时间的时间单位
         * 5.阻塞队列 7种
         * 6.线程工厂
         * 7.拒绝策略 4种
         */
        poolExecutor = new ThreadPoolExecutor(4, 10,
                10, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10),
                Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
        poolExecutor.execute(()->{

        });


    }

    public static class Hoder {
        private static final ThreadUtil POOL_EXECUTOR = new ThreadUtil();
    }

    public static ThreadUtil getInstance() {
        return Hoder.POOL_EXECUTOR;

    }
}
